import request from '@/utils/request'
import type {
  CertificatesTypeResponseData,
  OrderDetailResponseData,
  OrderStatusResponseData,
  PayStatusResponseData,
  QrCodeResponseData,
  SubmitOrderResponseData,
  UserAuth,
  UserInfoResponseData,
  UserOderResponseData,
} from './type'

enum API {
  // 提交订单获取订单号的接口地址
  SUBMIT_ORDER_URL = '/order/orderInfo/auth/submitOrder/',
  // 根据订单号获取订单详情的接口地址
  ORDER_DETAIL_URL = '/order/orderInfo/auth/getOrderInfo/',
  // 取消订单的接口地址
  CANCEL_ORDER_URL = '/order/orderInfo/auth/cancelOrder/',
  // 获取支付二维码的接口地址
  PAY_QRCODE_URL = '/order/weixin/createNative/',
  // 查询订单支付结果的接口地址
  PAY_STATUS_URL = '/order/weixin/queryPayStatus/',
  // 获取用户实名认证信息的接口地址
  USER_INFO_URL = '/user/auth/getUserInfo',
  // 获取证件类型的接口地址
  CERTIFICATES_TYPE_URL = '/cmn/dict/findByDictCode/',
  // 用户实名认证的接口地址
  USER_AUTH_URL = '/user/auth/userAuah',
  // 获取用户全部订单的接口地址
  USER_ALL_ORDER_URL = '/order/orderInfo/auth/',
  // 获取订单全部状态的接口地址
  ORDER_STATUS_URL = '/order/orderInfo/auth/getStatusList',
}
// 提交订单获取订单号的接口方法
export const reqSubmitOder = (
  hosCode: string,
  docCode: string,
  patientId: number,
) =>
  request.post<any, SubmitOrderResponseData>(
    API.SUBMIT_ORDER_URL + `${hosCode}/${docCode}/${patientId}`,
  )
// 根据订单号获取订单详情的接口方法
export const reqOrderDetail = (orderId: number) =>
  request.get<any, OrderDetailResponseData>(API.ORDER_DETAIL_URL + orderId)
// 取消订单的接口方法
export const reqCancelOrder = (orderId: number) =>
  request.get<any, any>(API.CANCEL_ORDER_URL + orderId)
// 获取微信支付二维码的接口方法
export const reqQrCode = (orderId: number) =>
  request.get<any, QrCodeResponseData>(API.PAY_QRCODE_URL + orderId)
// 查询当前订单的支付状态的接口方法
export const reqPayStatus = (orderId: number) =>
  request.get<any, PayStatusResponseData>(API.PAY_STATUS_URL + orderId)
// 获取当前用户实名认证的接口方法
export const reqUserInfo = () =>
  request.get<any, UserInfoResponseData>(API.USER_INFO_URL)
// 获取证件类型的接口方法
export const reqCertificatesType = (type: string) =>
  request.get<any, CertificatesTypeResponseData>(
    API.CERTIFICATES_TYPE_URL + type,
  )
// 用户实名认证的接口方法
export const reqUserAuth = (data: UserAuth) =>
  request.post<any, any>(API.USER_AUTH_URL, data)
// 获取用户用户全部订单数据的接口方法
export const reqUserOrder = (
  page: number,
  limit: number,
  patientId?: string,
  orderStatus?: string,
) =>
  request.get<any, UserOderResponseData>(
    API.USER_ALL_ORDER_URL +
      `${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`,
  )
// 获取订单全部状态的接口方法
export const reqOrderStatus = () =>
  request.get<any, OrderStatusResponseData>(API.ORDER_STATUS_URL)
